﻿/**
 * Proyecto: Cognitum
 * Global IT Services 2008
 * @author
 */
Cognitum.Polizas.Auto.Entity = function(){
    if (LOG.isDebugEnabled()) {
        LOG.debug('[Cognitum.Polizas.Auto.Entity.ctor] <-');
    }
    Cognitum.Polizas.Auto.Entity.superclass.constructor.call(this);
}

Ext.extend(Cognitum.Polizas.Auto.Entity, Karma.Core.Entity, {
    id: 'Autos.Entity',
    name: 'Autos',
    editorXType: 'pol.autObj.editor',
    editorW: 520,
    editorH: 540,
    columns: [{
        Name: 'Id',
        Property: 'Id',
        Mostrar: false
    }, {
        Name: 'Serie',
        Property: 'Serie'
    }, {
        Name: 'Motor',
        Property: 'Motor'
    }, {
        Name: 'Placas',
        Property: 'Placas'
    }, {
        Name: 'Modelo',
        Property: 'Modelo'
    }, {
        Name: 'Marca',
        Property: 'Marca.Descripcion'
    }, {
        Name: 'Prima',
        Property: 'Prima'
    }, {
        Name: 'Conductor Habitual',
        Property: 'ConductorHabitual'
    }, {
        Name: 'Version',
        Property: 'Version'
    }, {
        Name: 'Estatus',
        Property: 'Estatus',
        Tipo: 'enum',
        TipoEnum: 'Cognitum.Dominio.Polizas.EstatusBienAseguradoEnum'
    }],
    titleProperty: new Ext.XTemplate('{Serie}, {Modelo}, {Version}'),
    searchlist: {
        canNew: false,
        canUpdate: false,
        canDelete: false,
        grouping: true,
        sortings: ['Serie'],
        views: [{
            Id: 0,
            Nombre: 'Normal',
            Template: null
        }, {
            Id: 1,
            Nombre: 'Expandida',
            Template: null
        }],
        previewTemplate: null
    },
    link: {
        displayProperty: new Ext.XTemplate('{Modelo}, {Version}'),
		tpl: '<span><h3>Inciso: {Inciso} </h3></span> {Modelo}, {Version}'
    },
    aggregatelist: {
        canNew: true,
        canUpdate: true,
        canDelete: false,
        newRecord: function(){
            var parameters = null;
            if (Ext.isEmpty(this.parentEntity.Poliza)) {
                parameters = {
                    Id: this.parentEntity.Id
                };
            }
            else {
                parameters = [{
                    Id: this.parentEntity.Poliza.Id
                }, {
                    Id: this.parentEntity.Id
                }];
            }
            this.entity.NewFromEntity(parameters, {
				flush: {
					fn: function(result, form){
						this.reload();
					},
					scope: this
				}
			});
        }		
    }
});

Cognitum.Autos = Cognitum.Polizas.Auto.Entity;
